using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using OpenTK.Math;

namespace Dogfight2008.Tests
{
  [TestFixture]
  public class Box2dFixture
  {
    [Test]
    public void Construct()
    {
      // anchor, axisamin,axisamax, axisbmin,axisbmax, rotation
      Box2d box = new Box2d(0, 0, -1, 1, -1, 1, 0);
    }

    [Test]
    public void AccessorsAreCorrect()
    {
      Box2d box = new Box2d(0, 1, -2, 3, -4, 5, 6);
      Assert.AreEqual(0, box.X);
      Assert.AreEqual(1, box.Y);
      Assert.AreEqual(-2, box.Amin);
      Assert.AreEqual(3, box.Amax);
      Assert.AreEqual(-4, box.Bmin);
      Assert.AreEqual(5, box.Bmax);
      Assert.AreEqual(6, box.Rotation);
    }

    [Test]
    public void ABoxIntersectsItselfForSure()
    {
      Box2d box = new Box2d(0, 0, -1, 1, -1, 1, 0);
      Assert.IsTrue(box.Intersects(box));
    }

    [Test]
    public void TwoHorisontalNonIntersectingBoxes()
    {
      Box2d b1 = new Box2d(0, 0, -1, 1, -1, 1, 0);
      Box2d b2 = new Box2d(3, 0, -1, 1, -1, 1, 0);
      Assert.IsFalse(b1.Intersects(b2));
    }

    [Test]
    public void TwoVerticalNonIntersectingBoxes()
    {
      Box2d b1 = new Box2d(0, 0, -1, 1, -1, 1, 0);
      Box2d b2 = new Box2d(0, 3, -1, 1, -1, 1, 0);
      Assert.IsFalse(b1.Intersects(b2));
    }

    [Test]
    public void BarelyHorisontalIntersecting()
    {
      Box2d b1 = new Box2d(0, 0, 0, 1, -1, 1, 0);
      Box2d b2 = new Box2d(0.9, 0, 0, 1, -1, 1, 0);
      Assert.IsTrue(b1.Intersects(b2));
    }
  }
}
